import 'package:flutter/material.dart';
import './recommend/recommend.dart';
import './phone/phone.dart';
import './home/homes.dart';
import './home_appliance/homeAppliance.dart';
//智能
import './intelligent/intelligent.dart';
// 厨具
import './kitchenware/kitchenware.dart';
// 服饰
import './apparel/apparel.dart';
// 鞋包
import './shoe_bag/shoeBag.dart';
class HomePage extends StatelessWidget {
   @override
  Widget build(BuildContext context) {
    return  new DefaultTabController(
        length: choices.length,
        child: new Scaffold(
          appBar: new AppBar(
            leading: Container(
              width: 40,
              child: Image.asset('images/navi_title_v4.png'),
            ),
            automaticallyImplyLeading: false,
            actions: <Widget>[
              Container(
              width: 40,
              child: Icon(Icons.notifications_none),
              )
            ],
            // title两边距离
            titleSpacing: 0,
            title: BarSearch(),
            centerTitle: true,
            bottom: new TabBar(
              // 是否可滚动
              isScrollable: true,
              // 选中文字颜色
              labelColor: Color(0xff845F3F),
              // 下划线高度
              indicatorWeight:5,
              // 下划线颜色
              indicatorColor:Color(0xff845F3F) ,
              unselectedLabelColor: Colors.black,
              tabs: choices.map((Choice choice) {
                return new Tab(
                  text: choice.title,
                  // icon: new Icon(choice.icon),
                );
              }).toList()
            ),
          ),
          body: new TabBarView(
            children: <Widget>[
                new RecommendPage(),
                new PhonePage(),
                new HomesPage(),
                new HomeAppliancePage(),
                new IntelligentIPage(),
                new KitchenwarePage(),
                new ApparelPage(),
                new ShoeBagPage()
            ],
          ),
        ),
    );
  }
}
class BarSearch extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
     return Container(
        height: 35,
        padding: const EdgeInsets.only(left: 10,right: 10),
        decoration: BoxDecoration(
          border: Border.all(color: Color(0xfff4f4f4)),
          color: Color(0xfff4f4f4),
          borderRadius: BorderRadius.all(const Radius.circular(3.0)),
        ),
        child: Row(
          children: <Widget>[
            Icon(Icons.search,color: Color(0xff999999),),
            Expanded(
              child:Container(
                child: Text("除了佩奇更适合送的玩具",style: TextStyle(color: Color(0xff999999),fontSize: 18),),
              ),
            ),
            GestureDetector(
              child: Icon(Icons.center_focus_strong,color: Color(0xff999999)),
              onTap: (){
                print("object");
              },
            ),
          ],
        ),
      );
  }
}
  class Choice {
    const Choice({ this.title });
    final String title;
  }
  const List<Choice> choices = const <Choice>[
    const Choice(title: '推荐'),
    const Choice(title: '手机'),
    const Choice(title: '居家'),
    const Choice(title: '家电'),
    const Choice(title: '智能'),
    const Choice(title: '餐厨'),
    const Choice(title: '服饰'),
    const Choice(title: '鞋包'),
    // const Choice(title: '笔记本'),
    // const Choice(title: '影音'),
];

